package com.ecelin.tools;

/**
 * @author ecelin@ecelin.com
 */
public class DataInfo {
	private Integer index;
	private String dbName;
	private String tableName;
	private String columnName;
	private String columnDesc;
	private String dataType;
	private String length;
	private String priKey;
	private String autoIncrement;
	private String isNullable;
	private String defaultValue;
	private String tableDesc;
	private Long tableRows;
	private Long avgRowLength;
	private Long dataLength;

	public DataInfo(Integer index, String dbName, String tableName, String columnName, String columnDesc,
	                String dataType, String length, String priKey, String autoIncrement, String isNullable,
	                String defaultValue, String tableDesc, Long tableRows, Long avgRowLength, Long dataLength) {
		this.index = index;
		this.dbName = dbName;
		this.tableName = tableName;
		this.columnName = columnName;
		this.columnDesc = columnDesc;
		this.dataType = dataType;
		this.length = length;
		this.priKey = priKey;
		this.autoIncrement = autoIncrement;
		this.isNullable = isNullable;
		this.defaultValue = defaultValue;
		this.tableDesc = tableDesc;
		this.tableRows = tableRows;
		this.avgRowLength = avgRowLength;
		this.dataLength = dataLength;
	}

	public DataInfo() {
	}

	public Long getTableRows() {
		return tableRows;
	}

	public Long getAvgRowLength() {
		return avgRowLength;
	}

	public Long getDataLength() {
		return dataLength;
	}

	public void setTableRows(Long tableRows) {
		this.tableRows = tableRows;
	}

	public void setAvgRowLength(Long avgRowLength) {
		this.avgRowLength = avgRowLength;
	}

	public void setDataLength(Long dataLength) {
		this.dataLength = dataLength;
	}

	public Integer getIndex() {
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public String getColumnDesc() {
		return columnDesc;
	}

	public void setColumnDesc(String columnDesc) {
		this.columnDesc = columnDesc;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public String getLength() {
		return length;
	}

	public void setLength(String length) {
		this.length = length;
	}

	public String getPriKey() {
		return priKey;
	}

	public void setPriKey(String priKey) {
		this.priKey = priKey;
	}

	public String getAutoIncrement() {
		return autoIncrement;
	}

	public void setAutoIncrement(String autoIncrement) {
		this.autoIncrement = autoIncrement;
	}

	public String getIsNullable() {
		return isNullable;
	}

	public void setIsNullable(String isNullable) {
		this.isNullable = isNullable;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String getTableDesc() {
		return tableDesc;
	}

	public void setTableDesc(String tableDesc) {
		this.tableDesc = tableDesc;
	}

	public static final String DB_LIST = "show databases";
	public static final String DATA_INFO_LIST = "SELECT t.TABLE_SCHEMA 'dbName', t.TABLE_NAME 'tableName',IF ( t.TABLE_COMMENT = '', t.TABLE_NAME, t.TABLE_COMMENT ) 'tableDesc', c.COLUMN_NAME 'columnName', c.DATA_TYPE 'dataType', c.COLUMN_TYPE 'length',IF ( c.COLUMN_KEY = 'PRI', '√', '' ) 'priKey',IF ( c.IS_NULLABLE = 'YES', '√', '' ) 'isNullable',IF ( c.COLUMN_DEFAULT IS NULL, '', c.COLUMN_DEFAULT ) 'defaultValue',IF ( c.EXTRA = 'auto_increment', '√', '' ) 'autoIncrement',IF ( c.COLUMN_COMMENT = '', c.COLUMN_NAME, c.COLUMN_COMMENT ) 'columnDesc', t.TABLE_ROWS 'tableRows', t.AVG_ROW_LENGTH 'avgRowLength', t.DATA_LENGTH 'dataLength' FROM `information_schema`.`COLUMNS` c INNER JOIN `information_schema`.`TABLES` t ON c.TABLE_NAME = t.TABLE_NAME WHERE t.TABLE_SCHEMA IN ( ? ) ORDER BY t.TABLE_SCHEMA, t.TABLE_NAME, c.ORDINAL_POSITION";
}